import {Component, Input} from '@angular/core';
import {NzButtonComponent, NzButtonType} from "ng-zorro-antd/button";
import {ModalTypes, NzModalComponent, NzModalModule} from "ng-zorro-antd/modal";

type EmitterEvent = (() => void)

@Component({
  selector: 'app-modal-component',
  standalone: true,
  imports: [
    NzButtonComponent,
    NzModalComponent,
    NzModalModule
  ],
  templateUrl: './modal-component.component.html',
  styleUrl: './modal-component.component.scss'
})
export class ModalComponentComponent {
  @Input()
  title: string = "提示"
  @Input()
  content: string = "Content"
  @Input()
  okText: string = "Ok"
  @Input()
  cancelText: string = "Cancel"
  @Input()
  visible: boolean = false
  @Input()
  okType: string = "primary"
  @Input()
  cancelType: string = "default"
  @Input()
  nzModalType: ModalTypes = 'default';
  @Input()
  nzOkType: NzButtonType = "primary";

  showModal() {
    this.visible = true
  }

  @Input()
  handleCancel: EmitterEvent = () => {
    this.visible = false
  }
  @Input()
  handleOk: EmitterEvent = () => {
    this.visible = false
  }
  @Input()
  onClose: EmitterEvent = () => {
    this.visible = false
  }


  openModal() {
    this.visible = true
  }
}

